<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${message("添加车辆")}</title>
<link href="/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/reference/jquery.js"></script>
<script type="text/javascript" src="/resources/js/reference/jquery.validate.js"></script>
<script type="text/javascript" src="/resources/js/base/dialog.js"></script>
<script type="text/javascript" src="/resources/js/base/request.js"></script>
<script type="text/javascript" src="/resources/js/base/global.js"></script>
<script type="text/javascript" src="/resources/plugin/datePicker/WdatePicker.js"></script>
<link href="/resources/css/mmGrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/reference/mmGrid.js"></script>
<script src="/resources/js/base/file.js"></script>
<script type="text/javascript">
$().ready(function() {
	var $inputForm = $("#inputForm");

	// 表单验证
	$inputForm.validate({
		rules: {
			terminalNum: {
				required: true
			},
			terminalName: {
				required:true
			},
			sim:{
				digits:true
			},
			saleOrgId: {
				required:true
			},
		},
		messages: {
			username: {
				pattern: "${message("非法字符")}",
				remote: "${message("已存在")}"
			},
			password: {
				pattern: "${message("非法字符")}"
			}
			[#if !setting.isDuplicateEmail]
				,email: {
					remote: "${message("已存在")}"
				}
			[/#if]
		},
	});
	
	//查询机构
	$("#selectSaleOrg").bindQueryBtn({
		type:'saleOrg',
		title:'${message("查询机构")}',
		url:'/saleOrg/select_saleOrg.jhtml'
	});
	
	$("#selectCar").bindQueryBtn({
        type:'car',
        title:'${message("查询车辆")}',
		url:'/car/select_list.jhtml',
        callback:function(rows){
            if(rows.length>0){
				var row = rows[0];
				$("input[name='carNumber']").val(row.car_number);
            }
        }
    }); 
	
	[#if electronicFence!=null]
		var electronicFence = ${electronicFence};
	[#else]
		var electronicFence = {};
	[/#if]
	var rules={0:"${message("围栏内操作")}",1:"${message("围栏外操作")}"};
	var types={0:"${message("圆")}",1:"${message("多边形")}"};
	var cols = [				
		{ title:'${message("围栏名称")}', name:'name' ,align:'center', renderer: function(val,item,rowIndex, obj){
			var	html = '<input type="hidden" name="electronicFenceId" class="electronicFenceId electronicFenceId_'+item.id+'" value="'+item.id+'" />'+val;
			return html;}
		},
		{ title:'${message("类型")}', name:'type' ,align:'center',renderer:function(val,item,rowIndex){
			return types[val];
		}  },
    	{ title:'${message("位置")}', name:'points' ,align:'center',},
    	{ title:'${message("圆心经度")}', name:'longitude' ,align:'center' },
		{ title:'${message("圆心纬度")}', name:'latitude' ,align:'center' },
		{ title:'${message("半径(米)")}', name:'radius' ,align:'center' },
		{ title:'${message("判断规则")}', name:'judgment_rule' ,align:'center',renderer:function(val,item,rowIndex){
			return rules[val];
		} },
	];
	var $tmGrid=$('#table-electronicFence').mmGrid({
		fullWidthRows:true,
		height:'auto',
    	cols: cols,
    	checkCol: false,
    	items:electronicFence,
    	autoLoad: true,
	});
	
	
	 $("form").bindAttribute({
	 	isConfirm:true,
	    callback: function(resultMsg){
	        $.message_timer(resultMsg.type,resultMsg.content,1000,function(){
				location.href= 'edit.jhtml?id='+resultMsg.objx;
			})
	    }
	 });
	
});	
</script>
</head>
<body>
	<div class="pathh">
		&nbsp;${message("新增终端设备")}
	</div>
	<form id="inputForm" action="save.jhtml" method="post" type="ajax" validate-type="validate">
		<input type="hidden" name="memberType" value="ordinary" />
		<div class="tabContent">
			<table class="input input-edit">
			<tr>
				<th>
					<span class="requiredField">*</span>${message("终端设备编号")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" name="terminalNum" class="text " minlength="8" maxlength="8"   btn-fun="clear"/></span>
				</td>
				<th>
					<span class="requiredField">*</span>${message("终端名称")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" name="terminalName" class="text " maxlength="20"   btn-fun="clear"/></span>
				</td>
				<th>
					<span class="requiredField">*</span>${message("终端SIM卡号")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" name="sim" class="text "  btn-fun="clear"/></span>
				</td>
				<th>
					<span class="requiredField">*</span>${message("机构")}:
				</th>
				<td>
					<span class="search" style="position:relative">
					<input type="hidden" name="saleOrgId" class="text saleOrgId" btn-fun="clear" value="${saleOrg.id }"/>
					<input type="text" name="saleOrgName" class="text saleOrgName" maxlength="200" onkeyup="clearSelect(this)" value="${saleOrg.name }" readOnly/>
					<input type="button" class="iconSearch" value="" id="selectSaleOrg">
					</span>
				</td>
				<!--
				<tr class="partsShow border-L3">
				<th>
					${message("设备用户")}:
				</th>
				<td colspan="7">
					<a href="javascript:;" id="addMember" class="button">${message("设备用户")}</a>
				</td>
			</tr>
			<tr class="isSelectedTr border-L3">
				<th>
					&nbsp;
				</th>
				<td colspan="7">
					<div class="clearfix"></div>
					<table class="input  table-fixed" id="partsTable">
						<thead>
						<tr>
							<th>
								${message("用户名")}
							</th>
							<th>
								${message("手机号")}
							</th>
							<th>
								${message("姓名")}
							</th>
							<th style="width:70px">
								${message("操作")}
							</th>
						</tr>
						</thead>
						<tbody>
						<tr id="memberTr">
						</tr>
						</tbody>
					</table>
				</td>
			</tr>
			-->
			</tr>
			<tr>
				<th>
					${message("终端设备类型")}:
				</th>
				<td>
					<select id="typeId" name="typeId" class="text">
						[#list terminalTypes as terminalType]
						<option value="${terminalType.id}">${terminalType.value}</option>
						[/#list]
					</select>
				</td>
				<th>
					${message("终端设备型号")}:
				</th>
				<td>
					<select id="modelId" name="modelId" class="text">
						[#list terminalModels as terminalModel]
						<option value="${terminalModel.id}">${terminalModel.value}</option>
						[/#list]
					</select>
				</td>
				<th>
					<span class="requiredField">*</span>${message("车牌号")}:
				</th>
				<td>
					<span class="search" style="position:relative">
					<input type="text" name="carNumber" class="text carNumber" maxlength="200" onkeyup="clearSelect(this)" value=""/>
					<input type="button" class="iconSearch" value="" id="selectCar">
					</span>
				</td>
				<th>
					${message("备注")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" name="remark" class="text " maxlength="20"   btn-fun="clear"/></span>
				</td>
			</tr>
			<tr>
				<th>
					${message("是否开启基站定位")}:
				</th>
				<td>
					<label>
						<input type="checkbox" name="isJzdw" value="true"/>${message("开启")}
						<input type="hidden" name="_isJzdw" value="false" />
					</label>
				</td>
				<th>${message("是否手动开锁")}:</th>
				<td>
					<label>
						<input type="checkbox" name="isManualUnlock" value="true"/>${message("手动开锁")}
						<input type="hidden" name="_isManualUnlock" value="false" />
					</label>
				</td>
				<th>${message("是否手动解除报警")}:</th>
				<td>
					<label>
						<input type="checkbox" name="isManualRemoveWarn" value="true"/>${message("手动解除报警")}
						<input type="hidden" name="_isManualRemoveWarn" value="false" />
					</label>
				</td>
				<th></th><td></td>
			</tr>
			<tr class="partsShow border-L3">
				<th>
					${message("所在电子围栏")}:
				</th>
				<td colspan="7">
				</td>
				</tr>
				<tr class="border-L3">
            	<td colspan="8">
            		<div>
						<table id="table-electronicFence"></table>
					</div>
            	</td>
            	</tr>
		</table>
		</div>
		<div class="fixed-top">
			<input type="submit" id="submit_button" class="button sureButton" value="${message("1013")}" />
			<input type="button" onclick="location.reload(true);" class="button resetButton ml15" value="${message("重置")}">
		</div>
	</form>
</body>
</html>